package com.thank.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.thank.validator.MyCustomerValid;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Past;
import java.util.Date;

/**
 * description: none
 *
 * @author thank
 * 2018/2/19 0:44
 */
public class User {

    // 使用接口来声明多个视图
    public interface UserSimpleView {};
    public interface UserDetailView extends UserSimpleView {};

    private String id;

    @MyCustomerValid(message = "这是一个自定义校验的测试")
    private String username;

    @NotBlank
    private String password;

    @Past(message = "生日不能是未来的")
    private Date birthday;

    @JsonView(UserSimpleView.class)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @JsonView(UserSimpleView.class)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @JsonView(UserDetailView.class)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", birthday=" + birthday +
                '}';
    }
}
